home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Chat / App.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  4.0 KB  |  108 lines  |  [TEXT/MPS ]

  1. #ifndef __APPHEADER__
  2. #define __APPHEADER__
  3.  
  4. #ifndef __DTSLib__
  5. #include "DTS.Lib.h"
  6. #endif
  7.  
  8. #ifndef __PRINTING__
  9. #include <Printing.h>
  10. #endif
  11.  
  12. #ifndef __TREEOBJ__
  13. #include <TreeObj.h>
  14. #endif
  15.  
  16. /********/
  17.  
  18. /* If you are unfamiliar with programming with the DTS.framework, you probably want to
  19. ** read the file "=How to write your app", which is found at the same level as the
  20. ** directory for this project. */
  21.  
  22. typedef struct {
  23.     DocHeaderInfo    fhInfo;        /* Doc header info (version, print record, window loc. ) */
  24.     TreeObjHndl        root;
  25.                                 /***** Start of custom file info. *****/
  26.     Handle        textHndl;        /* Temporarily holds opened document text.
  27.                                 ** The document is first read in, and then a
  28.                                 ** window is created for it.  Until the window
  29.                                 ** is created, we can't have a TextEdit control.
  30.                                 ** This field holds the text that was read in
  31.                                 ** when the file was opened.  It is disposed of
  32.                                 ** after the TextEdit control is created and
  33.                                 ** holds the document text. */
  34.     TEHandle    inBox;            /* TextEdit in-box.  */
  35.     TEHandle    outBox;            /* TextEdit out-box. */
  36. } TheDoc;
  37.  
  38. /* Below is the master document structure.  All DTS.framework documents use this structure.
  39. ** For each unique document type, union in a sub-structure for the document-specific
  40. ** information.  In the case of DTS.Chat, there is only one document type.  The structure for
  41. ** this document type is defined just above.  Even though there is only one, it is still
  42. ** placed in a union.  This allows easy addition of additional document types later.
  43. ** Given a FileRec handle called frHndl, a sample dereference to the inBox field would look like:
  44. **     inBox = (*frHndl)->d.doc.inBox;
  45. **
  46. ** The fileState and connect fields are expected and managed by DTS.framework.  Also, the
  47. ** first two fields in the app-specific portion of the document are expected, namely
  48. ** the fhInfo and root fields. */
  49.  
  50. typedef struct FileRec {
  51.     FileStateRec    fileState;        /* DTS.Lib expects this structure here. */
  52.     ConnectRec        connect;        /* DTS.Lib expects this structure here. */
  53.     union {
  54.         TheDoc    doc;                /* Union in each document type here. */
  55.     } d;
  56. } FileRec;
  57.  
  58. /* Below is the definition of the hierarchical document's root object.  If you are using
  59. ** the hierarchical document package TreeObj, then you will need at least this object.
  60. ** TreeObj expects the first two fields to be undo and frHndl, as shown below.  You can
  61. ** add fields after these two fields.  If you use TreeObj, the root object and all of its
  62. ** children are automatically saved and read from disk.
  63. ** Note that the definition for the root object includes a prototype.  Each object is
  64. ** automatically called by DTS.framework at appropriate times.  The prototype defines the
  65. ** function that will be called for this object.  See the files "=How to write your app"
  66. ** and "=Using TreeObj.c" for more information. */
  67.  
  68. long    TRootObj(TreeObjHndl hndl, short message, long data);
  69. typedef struct {
  70.     TreeObjHndl    undo;        /* This structure may be added to, but */
  71.     FileRecHndl    frHndl;        /* these two first fields must remain. */
  72. } RootObj;
  73.  
  74. /********/
  75.  
  76. #define kMaxNumUndos  64
  77. #define kNumSaveUndos 8
  78.  
  79. #define kNumTreeObjs   16        /* Minimum number of objects is 16. */
  80.  
  81. #define mDerefRoot(hndl)     ((RootObj*)((*hndl) + 1))
  82.  
  83. /********/
  84.  
  85. /* These values are passed to the DTS.framework function Initialize(). */
  86. #define kMinHeap    64 * 1024        /* Needs at least 64k of heap space. */
  87. #define kMinSpace    64 * 1024        /* Needs this much after calling PurgeSpace. */
  88.  
  89.  
  90. #define kwAppWindow            (kwGrowIcon | kwVisible | kwOpenAtOldLoc)
  91.     /* Main application window has growIcon, is initially visible, and if the
  92.     ** document is saved, it will open at the location it was last close at. */
  93.  
  94. #define keyAppMessage      'KMSG'         /* Custom Apple Event definitions. */
  95. #define typeAppMessage     'KMSG'
  96. #define typeTextMessage    'KTXT'
  97.  
  98. #define kDisconnectMssg    0
  99. #define kTextMssg        1
  100.  
  101. #define kVersion        100        /* Document versions, not application versions. */
  102. #define kMinVersion        100
  103. #define kMaxVersion        100
  104.  
  105. #define kMaxNumWindows        65535        /* No limit on the number of windows. */
  106.  
  107. #endif __APPHEADER__
  108.